package com.sl.plugin.step.field;

import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.StrUtil;
import com.sl.core.engine.meta.ProcessCompDescriptorService;
import com.sl.core.engine.meta.impl.AbstractProcessCompDescriptor;
import com.sl.core.engine.meta.row.ProcessRowDescriptor;
import lombok.Getter;

import java.util.Map;

//@Comp(id = "ManyToOne", name = "多行转一行", desc = "多行转一行", groupName = "转换")
@Getter
public class FieldNameConvertCompDescriptor extends AbstractProcessCompDescriptor<
        FieldNameConvertComp, FieldNameConvertCompContext> implements ProcessCompDescriptorService {


    @Override
    public void loadDescriptor(Map<String, Object> map) {

    }


    @Override
    public ProcessRowDescriptor getResultDescriptor(ProcessRowDescriptor rowDescriptor) {

        Map<String, Object> am = getAttributeMap();

        Map<String, Object> output = MapUtil.get(am, "config", Map.class);

        String upperTrans = MapUtil.getStr(output, "upperTrans");
        String underLineTrans = MapUtil.getStr(output, "underLineTrans");

        //大写
        if (StrUtil.equals(upperTrans, "upper")) {
            rowDescriptor.toUpperCase();
        } else if (StrUtil.equals(upperTrans, "lower")) {
            rowDescriptor.toLowerCase();
        }

        //大写
        if (StrUtil.equals(underLineTrans, "underLine")) {
            rowDescriptor.toUnderLine();
        } else if (StrUtil.equals(underLineTrans, "cameCase")) {
            rowDescriptor.toCameCase();
        }

        return new ProcessRowDescriptor(rowDescriptor);
    }

//    private void setFiledName(ProcessRowDescriptor rowDescriptor, Boolean upper) {
//
//        List<IValueMeta> valueMetaList = rowDescriptor.getValueMetaList();
//
//        for (IValueMeta valueMeta : valueMetaList) {
//            String name = valueMeta.getName();
//            if (BooleanUtil.isTrue(upper)) {
//                valueMeta.setName(name.toUpperCase());
//            }
//            if(){
//
//            }
//        }
//    }


}
